<?php


namespace App\HttpController;


use EasySwoole\Http\AbstractInterface\Controller;

class Index extends \App\Base\ViewController
{

    public function __construct()
    {
        parent::__construct();

    }

    function index()
    {
        $this->response()->redirect('/welcome/login');
        
        $file = EASYSWOOLE_ROOT.'/vendor/easyswoole/easyswoole/src/Resource/Http/welcome.html';
        if(!is_file($file)){
            $file = EASYSWOOLE_ROOT.'/src/Resource/Http/welcome.html';
        }
        $this->response()->write(file_get_contents($file));
    }
    public function code(){
        $config = new \EasySwoole\VerifyCode\Conf();
        $code = new \EasySwoole\VerifyCode\VerifyCode($config);
        $obj = $code->DrawCode();
        //保存session
        $this->session()->start();
        $this->session()->set('CODE',$obj->getImageCode());
        //输出图片
        $this->response()->withHeader('Content-Type','image/png');
        $this->response()->write($obj->getImageByte());
    }
    /*
    public function set_session(){
        $this->session()->start();
        $this->session()->set('test',time());
        $this->response()->write('hello world');
    }
    public function get_session(){
        $this->session()->start();
        $time = $this->session()->get('test');
        echo $time;
        $this->response()->write('hello world');
    }
    */
}